<?php namespace App\Http\Requests;

use App\Http\Requests\Request;
use Validator;

class AdminUpdateRequest extends Request {

	/**
	 * Determine if the user is authorized to make this request.
	 *
	 * @return bool
	 */
	public function authorize()
	{
		return true;
	}

	/**
	 * Get the validation rules that apply to the request.
	 *
	 * @return array
	 */
	public function rules()
	{
		return [
			'name' => 'required|max:255|unique:users,name,' . $this->input('hid'),
			'password' => 'min:6',
			'notpass' => 'same:password',
			'email' => 'email',
		];
	}

	public function validator()
	{
		$nickName = [
			'name' => '管理员姓名',
			'password' => '管理员密码',
			'notpass' => '第二次输入密码',
			'email' => '电子邮件',
		];

		$validator = Validator::make($this->input(), $this->rules());
		$validator->setAttributeNames($nickName);

		return $validator;
	}

}
